package com.qianxx.component.activity.recycleview.slide_recycler_view;

import android.content.Context;
import android.view.View;

import com.qianxx.component.R;
import com.qianxx.viewlibrary.recyclerview.pull.adapter.BaseAdapter;
import com.qianxx.viewlibrary.recyclerview.pull.adapter.BaseViewHolder;

import java.util.ArrayList;

/**
 * 收藏
 */
public class SlideRecyclerViewAdapter extends BaseAdapter<String> {
    OnItemDeleteListener listener;

    public SlideRecyclerViewAdapter(Context context) {
        super(context, new ArrayList<String>(), R.layout.item_slide_recycler_view);
    }

    public void setOnItemRemoveListener(OnItemDeleteListener listener) {
        this.listener = listener;
    }

    @Override
    public void onBind(BaseViewHolder holder, int viewType, final int position, final String item) {
        holder.getView(R.id.tv_delete).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (listener != null)
                    listener.onDelete(position, item);
            }
        });
    }

    public interface OnItemDeleteListener {
        void onDelete(int position, String entity);
    }
}
